﻿using System.Collections.ObjectModel;
using FluentValidation.Attributes;
using Nop.Admin.Models.Catalog;
using Nop.Admin.Validators.Stores;
using Nop.Core.Domain.Directory;
using Nop.Web.Framework;
using Nop.Web.Framework.Localization;
using Nop.Web.Framework.Mvc;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
using Telerik.Web.Mvc;

namespace Nop.Admin.Models.Stores
{
    [Validator(typeof(StoreValidator))]
    public partial class StoreModel : BaseNopEntityModel, ILocalizedModel<StoreLocalizedModel>
    {
        public StoreModel()
        {
            if (PageSize < 1)
            {
                PageSize = 5;
            }
            Locales = new List<StoreLocalizedModel>();
            RegionCollection=new Collection<Region>();
        }

        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.Name")]
        [AllowHtml]
        public string Name { get; set; }

        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.FullDescription")]
        [AllowHtml]
        public string Description { get; set; }

        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.MetaKeywords")]
        [AllowHtml]
        public string MetaKeywords { get; set; }

        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.MetaDescription")]
        [AllowHtml]
        public string MetaDescription { get; set; }

        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.MetaTitle")]
        [AllowHtml]
        public string MetaTitle { get; set; }

        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.SeName")]
        [AllowHtml]
        public string SeName { get; set; }

        [UIHint("Picture")]
        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.Picture")]
        public int PictureId { get; set; }

        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.PageSize")]
        public int PageSize { get; set; }

        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.PriceRanges")]
        [AllowHtml]
        public string PriceRanges { get; set; }

        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.Published")]
        public bool Published { get; set; }

        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.Featured")]
        public bool Featured { get; set; }

        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.Deleted")]
        public bool Deleted { get; set; }
        public bool IsAdmin { get; set; }
        public bool IsStoreAdmin { get; set; }

        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.DisplayOrder")]
        public int DisplayOrder { get; set; }

        public IList<StoreLocalizedModel> Locales { get; set; }

        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.MinOrderSubtotalAmount")]
        public decimal MinOrderSubtotalAmount { get; set; }

        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.MinOrderTotalAmount")]
        public decimal MinOrderTotalAmount { get; set; }

        [UIHint("Picture")]
        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.Banner")]
        public int BannerId { get; set; }

        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.CustomerEmail")]
        public string CustomerEmail { get; set; }
        public int BillToCustomerId { get; set; }
        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.MainBranchId")]
        public int? MainBranchId { get; set; }

        #region Commerce Order service fee
        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.StorageAmount")]
        public decimal StorageAmount { get; set; }
        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.StorageChargeRate")]
        [UIHint("DecimalNullable")]
        public decimal? StorageChargeRate { get; set; }
        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.MonthlyCharge")]
        public decimal MonthlyCharge { get; set; }
        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.ServiceChargeRate")]
        public decimal ServiceChargeRate { get; set; }
        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.TransactionProcessingChargeRate")]
        [UIHint("DecimalNullable")]
        public decimal? TransactionProcessingChargeRate { get; set; }
        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.AdminCustomerId")]
        public int AdminCustomerId { get; set; }
        public ICollection<Region> RegionCollection { get; set; }
        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.RegionId")]
        public int RegionId { get; set; }
        #endregion

        #region Nested classes

        public partial class AddStoreProductModel : BaseNopModel
        {
            public AddStoreProductModel()
            {
                AvailableCategories = new List<SelectListItem>();
            }
            public GridModel<ProductModel> Products { get; set; }

            [NopResourceDisplayName("Admin.Catalog.Products.List.SearchProductName")]
            [AllowHtml]
            public string SearchProductName { get; set; }
            [NopResourceDisplayName("Admin.Catalog.Products.List.SearchCategory")]
            public int SearchCategoryId { get; set; }
            [NopResourceDisplayName("Admin.Catalog.Stores.SearchStore")]
            public int SearchStoreId { get; set; }

            public IList<SelectListItem> AvailableCategories { get; set; }

            public int StoreId { get; set; }

            public int[] SelectedProductIds { get; set; }
        }

        #endregion
    }

    public partial class StoreLocalizedModel : ILocalizedModelLocal
    {
        public int LanguageId { get; set; }

        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.Name")]
        [AllowHtml]
        public string Name { get; set; }

        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.FullDescription")]
        [AllowHtml]
        public string Description { get; set; }

        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.MetaKeywords")]
        [AllowHtml]
        public string MetaKeywords { get; set; }

        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.MetaDescription")]
        [AllowHtml]
        public string MetaDescription { get; set; }

        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.MetaTitle")]
        [AllowHtml]
        public string MetaTitle { get; set; }

        [NopResourceDisplayName("Admin.Catalog.Stores.Fields.SeName")]
        [AllowHtml]
        public string SeName { get; set; }
    }
}